package com.atguigu.tingshu.search.api;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.AlbumInfo;
import com.atguigu.tingshu.query.search.AlbumIndexQuery;
import com.atguigu.tingshu.search.service.SearchService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "搜索专辑管理")
@RestController
@RequestMapping("/api/search/albumInfo")

public class SearchApiController {

    @Autowired
    private SearchService searchService;


    @PostMapping()
    public Result seach(@RequestBody AlbumIndexQuery albumIndexQuery){
       return Result.ok(searchService.seach(albumIndexQuery)) ;
    }



    /**
     *  查询前七名的三级分类下的 前六名专辑数据
     * @param category1Id
     * @return
     */
    @GetMapping("channel/{category1Id}")
    public Result channel(@PathVariable(value = "category1Id") Long category1Id){
        return Result.ok(searchService.channel(category1Id));
    }


    @GetMapping("/{albumId}")
    public Result albumInfo(@PathVariable(value = "albumId") Long albumId){
        return Result.ok(searchService.albumInfo(albumId));
    }

    @GetMapping("/findRankingList/{category1Id}/{hotScore}")
    public Result findRankingList(@PathVariable(value = "category1Id")Long category1Id,
                                  @PathVariable(value = "hotScore")String hotScore){
        return Result.ok(searchService.findRankingList(category1Id,hotScore));
    }
}

